package fr.lelouet.ga.reducers.competitors;

import fr.lelouet.ga.reducers.Competitor;

/**
 * Competitor that owns another competitor and select the loser as the winner of
 * the other competitor
 * 
 * @author admin
 * 
 */
public class InverseCompetitor<T> implements Competitor<T> {

    protected Competitor<T> other;

    public InverseCompetitor(Competitor<T> other) {
	this.other = other;
    }

    @Override
    public T loser(T a, T b) {
	if (other.loser(a, b) == a) {
	    return b;
	} else {
	    return a;
	}
    }

}
